package src

import (
	"log/slog"

	"gopkg.in/ini.v1"
)

var Logger *slog.Logger

const (
	SUCCESS = 200
	ERROR   = 400
)

var MSG = map[int]string{
	SUCCESS: "成功",
	ERROR:   "失败",
}

func GetMsg(code int) string {
	return MSG[code]
}

func GetIniConfig(secton string, key string) string {
	//log.Println("读取配置：" + secton + "[" + key + "]")
	Logger.Info("读取配置：" + secton + "[" + key + "]")
	cfg, err := ini.Load("config.ini")

	if err != nil {
		Logger.Warn("读取配置失败：" + err.Error())
		return ""
	}
	value := cfg.Section(secton).Key(key).String()
	Logger.Info("config: " + secton + "[" + key + "]: " + value)
	return value
}
